<!doctype html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta
            name="viewport"
            content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"
        />
        <meta
            name="format-detection"
            content="telephone=no,email=no,date=no,address=no"
        />
        <title></title>
        <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
        <script src="../../script/jquery.js"></script>
        <script src="../../CommonTool/commonNetWork.js"></script>
        <style>
            body {
                background-color: #03a9f4;
            }

            #frm-container {
                margin: 0 auto;
                width: 83%;
                height: 100%;
                border-radius: 20px;
                border: 2px solid white;
                padding: 5px 10px;
                background: white;
            }

            #footer {
                background: none;
                position: absolute;
                bottom: 0;
            }
        </style>
    </head>

    <body>
        <header class="aui-bar aui-bar-nav" id="aui-header">
            <div class="aui-pull-left aui-btn" onclick="close_win();">
                <span class="aui-iconfont aui-icon-left"></span>返回
            </div>
        </header>
        <div id="frm-container" class="aui-content-padded">
            <div
                class="aui-tab aui-margin-t-10 aui-margin-b-5 aui-font-size-18"
            >
                <div style="color: #03a9f4; margin: 0 auto">请设置用户名</div>
            </div>

            <div
                class="aui-hr"
                style="
                    width: 90%;
                    margin: 0 auto;
                    border-top: 0.05rem solid #03a9f4;
                "
            ></div>
            <section class="aui-content-padded">
                <ul class="aui-list aui-form-list">
                    <li class="aui-list-item">
                        <div class="aui-list-item-inner">
                            <div class="aui-list-item-input">
                                <!-- <input type="text" onkeyup="value=value.replace(/[^\a-\z\A-\Z]/g,'')" placeholder="请输入用户名" pattern="[A-z]" id="login_username"> -->
                                <input
                                    type="text"
                                    onkeyup=""
                                    placeholder="请输入用户名"
                                    id="login_username"
                                />
                            </div>
                        </div>
                    </li>
                </ul>
                <div
                    style="
                        color: #aaaaaa;
                        font-size: 0.6rem;
                        margin-top: 0.5rem;
                    "
                ></div>
            </section>
            <div style="color: #aaaaaa; font-size: 0.6rem; margin-top: 0.5rem">
                修改用户名后需重新登录！
            </div>
            <section class="aui-content-padded">
                <div
                    class="aui-btn aui-btn-block aui-btn-info aui-btn-sm aui-font-size-18"
                    style="margin-top: 7rem"
                    tapmode
                    onclick="change_username();"
                >
                    确认
                </div>
                <div
                    class="aui-btn aui-btn-block aui-btn-info aui-btn-sm aui-font-size-18"
                    style="margin-top: 1rem; margin-bottom: 5rem"
                    tapmode
                    onclick="close_win();"
                >
                    取消
                </div>
            </section>
        </div>
    </body>
    <script type="text/javascript" src="../../../script/api.js"></script>
    <script>
         var token;
         var keyid 
         apiready = function () {
         token = api.pageParam.token;
         keyid=api.pageParam.keyid
         }
        function change_username() {
            $.ajax({
                url: CommonUrl + "/tSysUser/update",
                method: "post",
                dataType: "json",
                contentType: "application/json",
                headers: {
                    Authorization: `Bearer ${token}`,
                },
                data: JSON.stringify({
                    id: keyid,
                    sname:document.getElementById("login_username").value, 
                }),
                success: function (data) {
                    alert("上传成功");
                },
                error: function (error) {
                    alert(JSON.stringify(error));
                    },
                });
    }
        function close_win() {
            api.openWin({
                name: "MainMenu",
                url: "./../MainMenu.html",
                reload: true,
            });
        }
    </script>
    
    <!-- <script type="text/javascript">
    var user_id;
    apiready = function () {
        user_id = api.pageParam.userID;
        api.parseTapmode();
        $api.fixStatusBar($api.byId('aui-header'));
        $api.css($api.byId('frm-container'), 'height:' + (api.frameHeight - 48 - $api.offset($api.byId('aui-header')).h) * 1.2 + 'px;');
    }


    function close_win() {
        //api.closeWin({});
        api.openWin({
            name: 'completeInfo_gender',
            url: './gender.html',
            pageParam: {
                userID: user_id,
                login_user_name: api.pageParam.login_user_name,
                login_password: api.pageParam.login_password,
            }
        });
    }
</script> -->
</html>
